package com.easy.customer.service;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.easy.common.bean.Customers;
import com.easy.customer.mapper.CustomerMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CustomerService implements com.easy.common.service.ICustomerService {
    @Autowired
    CustomerMapper customerMapper;

    @Override
    public Customers insert(Customers customers) {
        System.out.println(customers);
        customerMapper.insert(customers);
        Customers result=customerMapper.selectById(customers.getId());
        return result;
    }

    @Override
    public Customers update(Customers customers) {
        customerMapper.updateById(customers);
        Customers result=this.getByID(customers.getId());
        return result;
    }

    @Override
    public int delete(Integer id) {
        int number=customerMapper.deleteById(id);
        return number;
    }

    @Override
    public Customers getByID(Integer id) {
        Customers result=customerMapper.selectById(id);
        return result;
    }

    @Override
    public IPage<Customers> getListByPage(IPage page, Customers customers) {
        Wrapper wrapper=new QueryWrapper();
        IPage result=customerMapper.selectPage(page,wrapper);
        return result;
    }

    @Override
    public List<Customers> getList(Customers customers) {
       Wrapper wrapper=new QueryWrapper();
       List<Customers> result=customerMapper.selectList(wrapper);
       return result;
    }

}
